<?php

use Illuminate\Database\Seeder;
use App\Models\Entrust\Role;
use App\Models\Entrust\Permission;

class Roles extends Seeder
{
    protected $roles = [
        ['name' => 'admin', 'description' => '超级管理员'],
        ['name' => 'director', 'description' => '处长'],
        ['name' => 'deputy_director', 'description' => '副处长'],
        ['name' => 'principal', 'description' => '部门负责人'],
        ['name' => 'main_principal', 'description' => '部门主要负责人'],
        ['name' => 'staff', 'description' => '一般职工'],
    ];

    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Role::insert($this->roles);

        $admin = Role::where('name', 'admin')->first();
        $admin->savePermissions(Permission::pluck('id'));
    }
}
